package com.xk.page.web;

import com.xk.page.service.PageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Controller
public class PageController {
    @Autowired
    private PageService pageService;
    @GetMapping("item/{id}.html")
    public String toItemPage(Model model,@PathVariable("id") Long id){
        Map<String,Object> map = pageService.toItemPage(id);
        //将数据放入模型中
        model.addAllAttributes(map);
        return "item";//跳转到模板item.html文件中
    }
}
